import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    visible: true
    width: 800
    height: 600
    title: "QML Loader 示例"

    RowLayout {
        anchors.fill: parent
        spacing: 10

        // 左侧选择栏
        ListView {
            Layout.preferredWidth: 200
            Layout.fillHeight: true
            model: [
                "文件加载",
                "组件加载",
                "加载状态",
                "动态标签",
                "创建控件",
                "延迟加载",
                "切换组件"
            ]
            delegate: ItemDelegate {
                width: parent.width
                text: modelData
                highlighted: ListView.isCurrentItem
                onClicked: {
                    listView.currentIndex = index
                    switch(index) {
                        case 0: mainLoader.source = "LoaderFile.qml"; break
                        case 1: mainLoader.source = "LoaderComponent.qml"; break
                        case 2: mainLoader.source = "LoaderStatus.qml"; break
                        case 3: mainLoader.source = "LoaderDynamicTab.qml"; break
                        case 4: mainLoader.source = "LoaderCreateControls.qml"; break
                        case 5: mainLoader.source = "LoaderDelay.qml"; break
                        case 6: mainLoader.source = "LoaderSwitch.qml"; break
                    }
                }
            }
            id: listView
        }

        // 右侧内容区
        Loader {
            id: mainLoader
            Layout.fillWidth: true
            Layout.fillHeight: true
            source: "LoaderFile.qml"
        }
    }
} 
